package cn.wwk.notification;

import cn.wwk.notification.feign.clients.LocationClient;
import cn.wwk.notification.feign.clients.UserClient;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * Hello world!
 *
 * @author wwk
 */
@SpringBootApplication
@EnableFeignClients(clients = {UserClient.class, LocationClient.class})
public class ELKApplication
{

    public static void main(String[] args) {
        SpringApplication.run(ELKApplication.class, args);
    }

    /**
     * 注入RestHighLevelClient Bean
     * */
    @Bean
    public RestHighLevelClient client(){
        return new RestHighLevelClient(RestClient.builder(
                HttpHost.create("http://43.138.21.102:9200")
        ));
    }

    /**
     * 创建RestTemplate并注入Spring容器
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
